//
//  NvEditAudioViewController.m
//  NvSellerShow
//
//  Created by dx on 17/2/13.
//  Copyright © 2017年 Meicam. All rights reserved.
//

#import "NvEditAudioViewController.h"
#import "NvPlaySlider.h"
@interface NvEditAudioViewController ()
@property (weak, nonatomic) IBOutlet UILabel *soundLabel;
@property (weak, nonatomic) IBOutlet UILabel *recordLabel;
@property (weak, nonatomic) IBOutlet NvPlaySlider *soundSlider;
@property (weak, nonatomic) IBOutlet NvPlaySlider *recordSlider;
- (IBAction)cancleButtonClick:(UIButton *)sender;
- (IBAction)sureBtnClick:(UIButton *)sender;
@property (weak, nonatomic) IBOutlet UIButton *cancleBtn;
@property (weak, nonatomic) IBOutlet UIButton *sureBtn;

@end

@implementation NvEditAudioViewController {
    float _sound;
    float _record;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    _soundSlider.value = _sound;
    _soundLabel.text = [self stringWithFloat:_sound];
    _recordSlider.value = _record;
    _recordLabel.text = [self stringWithFloat:_record];
    
    _cancleBtn.imageView.contentMode = UIViewContentModeScaleAspectFit;
    _sureBtn.imageView.contentMode = UIViewContentModeScaleAspectFit;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)soundSliderValueChanged:(id)sender {
    _sound = _soundSlider.value;
    _soundLabel.text = [self stringWithFloat:_sound];
}
- (IBAction)recordSliderValueChanged:(id)sender {
    _record = _recordSlider.value;
    _recordLabel.text = [self stringWithFloat:_record];
}
-(void)setSound:(float)sound {
    _sound = sound;
}

-(void)setRecord:(float)record {
    _record = record;
}
/**
 *  将整型转化为合适的字符串
 *
 */

- (NSString *)stringWithFloat:(float)volume {
    return [NSString stringWithFormat:@"%.f",volume*100];
}

- (IBAction)cancleButtonClick:(UIButton *)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (IBAction)sureBtnClick:(UIButton *)sender {
    [self dismissViewControllerAnimated:NO completion:^(){
        if(self.delegate != nil && [self.delegate respondsToSelector:@selector(didfinishSetSound:Record:)] ==YES) {
            [self.delegate didfinishSetSound:_sound Record:_record];
        }
    }];
}
@end
